package com.example.fw;

import org.openqa.selenium.By;
import com.example.tests.ContactData;

public class ContactHelper extends HelperBase {

	public ContactHelper(ApplicationManager manager) {
		super(manager);
	}

	public void submitContactCreation() {
		click(By.name("submit"));
	}

	public void fillContactPage(ContactData contact) {
		type(By.name("firstname"), contact.firstName);
		type(By.name("lastname"), contact.secondName);
		type(By.name("address"), contact.firstAddress);
		type(By.name("home"), contact.homeTel);
		type(By.name("mobile"), contact.mobileTel);
		type(By.name("work"), contact.workTel);
		type(By.name("email"), contact.email1);
		type(By.name("email2"), contact.email2);
		selectByText(By.name("bday"), contact.birthday);
		selectByText(By.name("bmonth"), contact.birthmonth);
		type(By.name("byear"), contact.birthyear);
		type(By.name("address2"), contact.secondAddress);
		type(By.name("phone2"), contact.secondTel);
	}


	public void returnHomePage() {
		click(By.linkText("home page"));
	}

	public void gotoContactPage() {
		click(By.linkText("add new"));
	}

	public void deleteContact() {
		click(By.xpath("//input[@value='Delete']"));
		
	}

	public void editContact(int index) {
		click(By.xpath("//input[@value='" + index + "']/../../td[@class='center']/a[@href]/img[@title='Edit']"));
		
	}

	public void updateContact() {
		click(By.name("update"));
		
	}

}
